/*
 * Fonctions pour gerer le formulaire valideurs
 * 
 */



function refreshCandidates(){
	
	idUM = document.getElementById('valideur_unitemanagerial_id').value;
	idCodeUm = document.getElementById('valideur_codeUm_id').value;
	idRegion = document.getElementById('valideur_region_id').value;
	idPlaque = document.getElementById('valideur_plaque_id').value;
	idDpt = document.getElementById('valideur_departement_id').value;
	idSite = document.getElementById('valideur_site_id').value;
	getXmlHttpRequest();
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200)
			{
			var textCandidates = xhr.responseText;
			var textCandidatesData = json_parse(textCandidates);
			refreshSelect('valideur_unitemanagerial_id', textCandidatesData['ums'], null, textCandidatesData['um']); 
			refreshSelect('valideur_codeUm_id', textCandidatesData['codesum'], null, textCandidatesData['codeum']);
			//refreshSelect('valideur_region_id', textCandidatesData['regions'], null, textCandidatesData['region']);
			refreshSelect('valideur_plaque_id', textCandidatesData['plaques'], null, textCandidatesData['plaque']);
			refreshSelect('valideur_departement_id', textCandidatesData['departements'], null, textCandidatesData['departement']);
			refreshSelect('valideur_site_id', textCandidatesData['sites'], null, textCandidatesData['site']);			
		}
	};
	xhr.open("POST","/backend.php/ajax/getInfosLocalisation.html",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("idUM="+idUM+"&idRegion="+idRegion+"&idPla="+idPlaque+"&idDpt="+idDpt+"&idSite="+idSite+'&idCodeUm='+idCodeUm);
}


$(document).ready(function(){    
	refreshCandidates();
});